package de.wbh.gwt.form.layouter.shared;

import javax.inject.Inject;

import com.google.gwt.place.shared.PlaceChangeEvent;
import com.google.web.bindery.event.shared.EventBus;

import de.wbh.gwt.form.layouter.shared.place.EditPlace;
import de.wbh.gwt.form.layouter.shared.place.StartPlace;

public class SkeletonPresenter implements PlaceChangeEvent.Handler {

	private final SkeletonView view;

	@Inject
	public SkeletonPresenter(EventBus eventBus, SkeletonView view) {
		eventBus.addHandler(PlaceChangeEvent.TYPE, this);
		this.view = view;
	}

	@Override
	public void onPlaceChange(PlaceChangeEvent event) {
		System.out.println("changed place: " + event.getNewPlace());
		if (event.getNewPlace() instanceof StartPlace) {
			this.view.showStartDeck(true);
		} else {
			this.view.showStartDeck(false);
			if (event.getNewPlace() instanceof EditPlace) {
				this.view.expandLeft();
			} else {
				this.view.shrinkLeft();
			}

		}
	}

}
